﻿using System;
using System.Reflection;

namespace CXW.Core.Sharp
{
    /// <summary>关于窗口</summary>
    partial class AboutBox : BaseForm
    {
        /// <summary>构造函数</summary>
        public AboutBox()
        {
            InitializeComponent();

            InitializeShow();
        }

        void InitializeShow()
        {
            //变更语言事件 此窗口无需调用,因为必须关闭此窗口才能变更语言 
            this.okButton.Text = ResourceService.GetString("Global.OK");

            //Assembly assembly = AppDomain.CurrentDomain.DomainManager.EntryAssembly;//此方法仅调试有值,原因未知
            Assembly assembly = Assembly.GetEntryAssembly();
            //窗口标题
            this.Text = ResourceService.GetString("Form.About") + " " + WorkbenchSingleton.Workbench.Title;
            //产品名称
            this.labelProductName.Text = WorkbenchSingleton.Workbench.Title;
            //版本
            this.labelVersion.Text = ResourceService.GetString("Global.Version") + " " + assembly.GetName().Version.ToString();
            //版权
            object[] attributes = assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
            if (attributes.Length == 0) { this.labelCopyright.Text = ""; }
            else { this.labelCopyright.Text = ((AssemblyCopyrightAttribute)attributes[0]).Copyright; }

            //公司名称
            attributes = assembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
            if (attributes.Length == 0) { this.labelCompanyName.Text = ""; }
            else { this.labelCompanyName.Text = ((AssemblyCompanyAttribute)attributes[0]).Company; }

            //说明
            attributes = assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
            if (attributes.Length == 0) { this.textBoxDescription.Text = ""; }
            else { this.textBoxDescription.Text = ((AssemblyDescriptionAttribute)attributes[0]).Description; }

        
            //foreach (Assembly item in AppDomain.CurrentDomain.GetAssemblies())
            //{
            //    ratingControl1.Text += item.GetName().Name + " " + item.ImageRuntimeVersion + " " + item.Location + "\r\n";
            //}
        }
    }
}
